<?php
/**
 * enable_error_logging.php
 * Tool for debugging hard-to-track-down issues
 *
 * @package utilities
 * @copyright Copyright 2003-2008 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: enable_error_logging.php 7842 2008-01-05 07:54:38Z drbyte $
 */

/**
*


  HOW TO USE: (ShopUpgraded style)

  set the line below to true like this

  $log_errors = true;

  and all Admin side error messages will be logged to the cache folder.
  these will be named like ADMINdebug-....log


*
*
**/


$log_errors = true;
















// ShopUpgraded note - section below
// does not work in Zen Cart either, needs fixing.

  $pages_to_debug[] = '*';
//   $pages_to_debug[] = '';
//   $pages_to_debug[] = '';
//   $pages_to_debug[] = '';
//   $pages_to_debug[] = '';
//   $pages_to_debug[] = '';
//   $pages_to_debug[] = '';
//   $pages_to_debug[] = '';

/**
 * The path where the debug log file will be located
 * Default value is: DIR_FS_SQL_CACHE . '/myDEBUG-00000000.log'
 * ... which puts it in the /cache/ folder:   /cache/myDEBUG-00000000.log  (where 0000000 is the server's timestamp)
 */
  $debug_logfile_path = DIR_FS_SQL_CACHE . '/ADMINdebug-' . time() . '.log';


if(!class_exists(smz_filesystem)){
  die('This module has been modified for a Shop Upgraded Installation, please visit <a ref="http://ShopUpgraded.com">http://ShopUpgraded.com</a>');
}

//print DIR_FS_SQL_CACHE.'/log_errors.unlock' ;

if($log_errors){

  $fc = new smz_filesystem;
  $fc->unlock(DIR_FS_SQL_CACHE);


  /**
  * Error reporting level to log
  * Default: E_ALL ^E_NOTICE
  */
    $errors_to_log = E_ALL ^E_NOTICE;



  ///// DO NOT EDIT BELOW THIS LINE /////

  //////////////////// DEBUG HANDLING //////////////////////////////////
    if (in_array('*', $pages_to_debug) || in_array($current_page_base, $pages_to_debug)) {
    /**
    * Sometimes it is difficult to debug PHP background activities
    * However, using the PHP error logging facility we can store all PHP errors to a file, and then review separately.
    * Using this method, the debug details are stored at: /cache/myDEBUG.log
    */
      @ini_set('log_errors', 1);          // store to file
      @ini_set('log_errors_max_len', 0);  // unlimited length of message output
      @ini_set('display_errors', 0);      // do not output errors to screen/browser/client
      @ini_set('error_log', $debug_logfile_path);  // the filename
      @ini_set('error_reporting', $errors_to_log );    // log only errors of more severity than NOTICE
    }


}

